const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');//打包之前 应用
const {CleanWebpackPlugin} = require('clean-webpack-plugin');//打包之后 应用 新写法

module.exports = {
    mode: 'development',
    // 项目的入口文件
    entry: {
        main: './src/index.js'
    },
    // 定位源代码的出错位置
    devtool: 'cheap-module-eval-source-map',
    module: {
        rules: [
            {test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"}
        ]
    },
    plugins: [
        new CleanWebpackPlugin(),
        new HtmlWebpackPlugin({
            filename: "index.html",
            template: "./index.html"
        })
    ],
    output: {
        filename: 'dist.js',// 打包后的文件名
        path: path.resolve(__dirname, 'dist')
    }
};